package com.flute.framework.autoprompt;

import java.util.HashSet;

public class SpecialChars {
	private static HashSet<Character> charSet;

	static {
		charSet = new HashSet<Character>();
		charSet.add(' ');
		charSet.add('-');
		charSet.add(',');
		charSet.add('\t');
	}

	public static boolean isSpeicalChars(char c) {
		return charSet.contains(c);
	}

	public static String getStatndardString(String string) {
		if (string == null) {
			string = "";
		}

		StringBuffer sb = new StringBuffer();
		char[] cs = string.toCharArray();
		char last = '1';
		for (int i = 0; i < cs.length; i++) {
			if (isSpeicalChars(cs[i])) {
				if (!isSpeicalChars(last)) {
					sb.append(" ");
				}
			} else {
				sb.append(cs[i]);
			}

			last = cs[i];
		}

		return sb.toString().trim();
	}
}
